package moodish.dummy;

import java.util.LinkedList;
import moodish.comm.ServerComm;
import moodish.comm.ServerSideMessage;
import moodish.server.Message;

public class ServerCommDummy implements ServerComm {
	
	LinkedList<ServerSideMessage> messageList = new LinkedList<ServerSideMessage>();   
	public void addMessage(ServerSideMessage message){
		messageList.add(message);
	}
	
	
	@Override
	public void start() {
    messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "Bruno"));
    messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "Ana"));	
    messageList.add(new Message(ServerSideMessage.Type.CLIENT_CONNECTED, "", "Goncalo"));
    
    messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Bruno", "Goncalo"));
    messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Bruno", "Ana"));
    messageList.add(new Message(ServerSideMessage.Type.FRIENDSHIP, "Ana", "Goncalo"));
    
    
    
	messageList.add(new Message(ServerSideMessage.Type.MOODISH_MESSAGE, "Sleepy", "Goncalo"));
	messageList.add(new Message(ServerSideMessage.Type.MOODISH_MESSAGE, "Annoyed", "Bruno"));

	messageList.add(new Message(ServerSideMessage.Type.UNFRIENDSHIP, "Ana", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.UNFRIENDSHIP, "Bruno", "Goncalo"));

	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "Bruno"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "Ana"));
	messageList.add(new Message(ServerSideMessage.Type.CLIENT_DISCONNECTED, "", "Goncalo"));
	
    
	}

	@Override
	public boolean hasNextMessage() {
		if(messageList.isEmpty()){
			return false;
		}
		return true;
	}

	@Override
	public ServerSideMessage getNextMessage() {
		ServerSideMessage message = messageList.removeFirst();
		return  message;
	}

	@Override
	public void sendNewFriendship(String toNickname, String newFriendship) {
		System.out.println(toNickname + newFriendship);
		
	}

	@Override
	public void sendError(String toNickname, String error) {
		System.out.println(toNickname + error);
		
	}

	@Override
	public boolean clientIsConnected(String nickname) {
		
		return false;
	}

	@Override
	public void sendClientConnected(String toNickname, String userConnected) {
		System.out.println(toNickname + userConnected);
		
	}

	@Override
	public void sendClientDisconnected(String toNickname, String userDisconnected) {
		System.out.println(toNickname + userDisconnected);
		
	}

	@Override
	public void disconnectClient(String nickname) {
		// TODO Auto-generated method stub
	}

	@Override
	public void sendMoodishMessage(String fromNickname, String toNickname,
			String message) {
		System.out.println(fromNickname + toNickname + message);
		
	}

	@Override
	public void sendNewUnfriendship(String toNickname, String newFriendship) {
		System.out.println(toNickname + newFriendship);
		
	}
}
